//
//  NSDateComponents+Compare.m
//
//  Created by zhaol on 10/14/15.
//  Copyright © 2015 zify. All rights reserved.
//

#import "NSDateComponents+Compare.h"

@implementation NSDateComponents(Compare)

+ (instancetype)componentsWithDate:(NSDate*)date
{
    NSCalendar *calendar = [NSCalendar currentCalendar];
    unsigned units  = NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute|NSCalendarUnitSecond|NSCalendarUnitWeekday|NSCalendarUnitWeekdayOrdinal;
    
    NSDateComponents *comps = [calendar components:units fromDate:date];
    return comps;
}

- (BOOL)isSameDay:(NSDateComponents*)comps
{
    if (comps&&
        self.year==comps.year&&
        self.month==comps.month&&
        self.day==comps.day) {
        
        return YES;
    }
    return NO;
}

@end
